/**
 * Called on the application's start. Adds important libraries,
 * which make the programmer's life much easier.
 */
var onStart = function() {
    app.addRepository('modules/core/HopObject.js');
    app.addRepository('modules/core/String.js');
    app.addRepository('modules/jala/code/ListRenderer.js');
}

/**
 * Converts a hash back into it's id. Note: this is just a really
 * simple way based on hexadecimal numbers. Only uppercase characters
 * are allowed in the hex-string!
 * 
 * @param hash to convert
 * @return the unique id
 */
var decodeHash = function(hash) {
    var id = parseInt(hash, 16);
    if (hash.match(/[a-z,G-Z]/) != null || isNaN(id)) {
        return NaN;
    }
    
    return id;
}

/**
 * Generate a hash for the given number.
 * @return hash of the Hyperlink
 */
var encodeHash = function(id) {
    if (isNaN(id)) { // is it a number?
        throw "Invalid number! " + id;
    }
    return Number(id).toString(16).toUpperCase();
}